from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class Base():
    # 初始化
    def __init__(self,driver):
        self.driver=driver
    def get(self,url):
        self.driver.get(url)

    def find_element(self,loc):
        return self.driver.find_element(*loc)
    # 点击
    def click(self,loc):
        self.find_element(loc).click()
    # 输入
    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)
    #断言
    def text(self,loc):
        self.find_element(loc).text()
#     切换页面
    def qiehuan(self):
        self.driver.switch_to.window(self.driver.window_handles[-1])
    # 隐式等待
    def implicitly_wait(self,loc):
        self.driver.implicitly_wait(loc)










    # 显示等待
    def WebDriverWait(self,loc,x):
        WebDriverWait(self.driver, 20, 10).until(EC.presence_of_element_located((self.driver.find_element(loc))))
